

import bpy
import 全局控制.Node.节点和插座基类.bl_节点基类 as 基类

import Core.bl_UI配色 as UI配色

import engine.initLIB.load_dll as engineLib
import ctypes







def f_update_变量生成(self, context):
	text = str(self.m_Code)
	text = text.split(",")
	data = []
	
	for i in text:
		try:
			data.append(float(i))
		except :
			pass
			
	engineLib.flexCAPI.f_node_传入BL数据(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), ctypes.py_object(data));

	if context :
		self.id_data.f_节点数据更新_更新树([self])



class C_Node_fromText_F32Array1D(基类.C_Node_基类):
	bl_dname = 'bl_node_fromText_F32ArrayD'
	bl_label = 'fromText F32ArrayD'

	m_Code = bpy.props.StringProperty(update=f_update_变量生成)
	def init(self, context):
		super(C_Node_fromText_F32Array1D, self).f_init(context)
		outSocket = self.outputs.new('C_Socket_F32_Array1D', name='var')

	def draw_buttons(self, context, layout):
		layout.prop(self, 'm_Code')

	def f_toCPP(self):
		engineLib.flexCAPI.f_创建从脚本生成变量节点(ctypes.c_wchar_p(self.id_data.name), ctypes.c_wchar_p(self.name), self.f_getPyObject());
		f_update_变量生成(self, None)

class C_NODE_MENU_fromText_F32Array1D(bpy.types.Operator):
	bl_idname = 'node.global_node_from_code_to_var_data'
	bl_label = 'fromText F32ArrayD'
	bl_options = {'REGISTER', 'UNDO'}
	def execute(operator, context):
		bpy.ops.node.add_node(type='C_Node_fromText_F32Array1D', use_transform=True)
		return {'FINISHED'}




classes = (
	C_Node_fromText_F32Array1D,
	C_NODE_MENU_fromText_F32Array1D,
	
)

def register():
	for c in classes:
		bpy.utils.register_class(c)
		
def unregister():
	for c in classes:
		bpy.utils.unregister_class(c)





